<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsppages/include/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title><%=system_name%> - 单证目录</title>
	<base href="<%=basePath%>" />
	<link type="image/x-icon" rel="shortcut icon" href="<%=basePath%>images/favicon.ico" />
 	<meta http-equiv="pragma" content="no-cache" />
 	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/common.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/userlist.css" rel="stylesheet" type="text/css" />
	<script src="<%=basePath%>js/common.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/pagebar_cn.js"></script>
	<script type="text/javascript" src="fram/engine.js" ></script>
	<script type="text/javascript" src="fram/util.js" ></script>
	<script type="text/javascript" src="fram/interface/shipService.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/DatePicker/WdatePicker.js" defer="defer"></script>	 
</head>

<body oncontextmenu='return false'>

	<!--top begin-->
	<%@include file="/WEB-INF/jsppages/admin/head.jsp"%>
	<!--top end-->


<div class="wrap100 content">

    <!--left begin-->
	<%@include file="/WEB-INF/jsppages/admin/left.jsp"%>
    <!--left end-->    
    
    <!--right begin-->
	<div class="right">
            <div class="search">
                <form action="<%=basePath%>trade/shipDirectoryList" method="GET">
                <table width="100%" border="0" cellspacing="0" cellpadding="5">
                  <tr>
                    <td width="5%"><img src="images/marking1.gif" width="41" height="44" alt="marking" /></td>
                    <td width="8%">快速查询</td>
                    <td width="25%">时间范围：<input type="text" name="startDate" id="startDate1" value="<fmt:formatDate value="${directorySearchCond.startDate}" pattern="yyyy-MM-dd"/>"  class="zi" style="width:75px;" onfocus="var end=document.getElementById('startDate2');WdatePicker({onpicked:function(){end.focus();},maxDate:end.value})"  autocomplete="off"/>
  					-<input type="text" name="startDate2" id="startDate2" value="<fmt:formatDate value="${directorySearchCond.startDate2}" pattern="yyyy-MM-dd"/>"  class="zi" style="width:75px;" onfocus="WdatePicker({minDate:'#F{$dp.$(\'startDate1\').value}'})"/></td>
                    </td>
                    <td width="20%">单证目录：<input type="text" name="directory" value="${directorySearchCond.directory}" style="width:100px;" /></td></td>
                    <td width="11%"><input type="hidden" id="id" name="id" value="${shipInfo.id}" />
                    <input type="submit" style="background:url(images/searchBtn.gif);width:116px;height:30px;border:0;margin:0;" value="" />
                    </td>
                    <td width="30%">
                    <jsp:useBean id="nowDate" class="java.util.Date"></jsp:useBean>
   					 现在是：${formatDate}<fmt:formatDate value="${nowDate}" type="both" dateStyle="full"/>
   					</td>
                    <td width="1%">&nbsp;</td>
                  </tr>
                </table>    
                </form>
         </div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="60"><h1><a href="docu.htm">单证目录</a><a href="xmate.htm"></a></h1></td>
              </tr>
            </table>
            <div class="rightContentTop">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="10%" align="center" bgcolor="#e3ecf1">船名</td>
                  <td width="17%">${shipInfo.shipName} </td>
                  <td width="11%" align="center" bgcolor="#e3ecf1">工程号</td>
                  <td width="62%">${shipInfo.jobnumber}</td>
                </tr>
              </table>
              <div class="subMenu">
               	  <ul>
                    	<li><a href="<%=basePath%>trade/shipLogList?id=${shipInfo.id}">船舶作业日志</a></li>
                        <li><a href="<%=basePath%>trade/shipShopMaterialList?id=${shipInfo.id}">船方自购物料</a></li>
                        <li><a href="<%=basePath%>trade/shipMainlandMaterialList?id=${shipInfo.id}">国内采购物料上船</a></li>
                        <li><a href="<%=basePath%>trade/shipFinalMaterialList?id=${shipInfo.id}">下船物料</a></li>
                        <li><a href="<%=basePath%>trade/shipDirectoryList?id=${shipInfo.id}" class="current">单证目录</a></li>
                    </ul>
                </div>				            
  		  </div>     
      
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="right"><span style="float:left;color:#666;">共找到<font color="red"> ${searchStat.totalCount} </font>条记录</span>
                	<c:if test="${sessionScope.memberSessionInfo.userType.value<2}">
                	<a href="javascript:;" onclick="addShipDirectory()" style="font-weight:bold"><img src="images/add.gif" width="90" height="31" alt="添加" /></a>
                	<!-- <a href="#"><img src="images/del.gif" width="90" height="31" alt="删除" /></a> -->
                	</c:if>
                	</td>
              </tr>
    	</table>
        <div class="rightContent1">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr class="td">
              <th width="4%" align="center" bgcolor="#f9f9f9"><input type="checkbox" name="checkbox4" id="checkbox4" /></th>
              <th width="3%" align="center" bgcolor="#f9f9f9">序号</th>
              <th width="6%" align="center" bgcolor="#f9f9f9">日期</th>
              <th width="8%" align="center" bgcolor="#f9f9f9">单证名录</th>
              <th width="11%" align="center" bgcolor="#f9f9f9">数量</th>
              <th width="7%" align="center" bgcolor="#f9f9f9">存档日期</th>
              <th width="37%" align="center" bgcolor="#f9f9f9">备注</th>
              <th width="16%" align="center" bgcolor="#f9f9f9">录入员</th>
              <th width="8%" align="center" bgcolor="#f9f9f9">操作</th>
            </tr>
            <c:forEach var="shipDirectory" items="${shipDirectoryList}">
            <tr>
              <td align="center"><input type="checkbox" name="checkbox" id="checkbox" /></td>
              <td align="center">${shipDirectory.id}</td>
              <td align="center"><fmt:formatDate value="${shipDirectory.startDate}" pattern="yyyy-MM-dd"/></td>
              <td align="center">${shipDirectory.directory}</td>
              <td>${shipDirectory.amount}</td>
              <td align="left"><fmt:formatDate value="${shipDirectory.saveDate}" pattern="yyyy-MM-dd"/></td>
              <td align="left">${shipDirectory.remark}</td>
              <td align="left">
                	${shipDirectory.user.name} <fmt:formatDate value="${shipDirectory.createDate}" pattern="yyyy-MM-dd"/></td>
              <td align="left">
              	<c:if test="${sessionScope.memberSessionInfo.userType.value<2}">
                	<a href="javascript:;" onclick="delShipDirectory('${shipDirectory.id}')"><img src="images/del1.jpg" alt="删除" /></a>
                	<a href="javascript:;" onclick="editShipDirectory('${shipDirectory.id}')"><img src="images/modify.jpg" alt="修改" /></a>
                </c:if>
              </td>
            </tr>
           </c:forEach>
			<c:if test="${empty shipDirectoryList}"><tr><td colspan="16" style="text-align:center">没有相关记录！</td></tr></c:if>
            
          </table>
        </div>
       <script type="text/javascript">
		var pageControl = new wpagebar('pageControl');
		pageControl.argName = "pageIndex";
		pageControl.pageCount =${searchStat.pageCount};
		pageControl.load();		
  	</script>     
    <div id="win_temp" style="display:none">
	<div id="winCon_1">
	<table class="tabView" style="margin-top:5px">
		<tr><th width="100">开始日期：</th><td>
		<input type="text" name="startDate0" id="startDate0" value="" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
		<input type="text" name="shipDirectoryId0" id="shipDirectoryId0" style="display:none"/></td></tr>
		<tr><th>存档日期：</th><td><input type="text" name="saveDate0" id="saveDate0" value="" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></td></tr>
		<tr><th>单证目录：</th><td><input type="text" name="directory0" id="directory0" maxlength="100"/></tr>
		<tr><th>数量：</th><td><input type="text" name="amount0" id="amount0" value="" maxlength="10" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)"/></td></tr>
		<tr><th>备注：</th><td><textarea id="remark0" name="remark0" rows="4" cols="40"></textarea></td></tr>
		<tr><th>状态：</th><td><input type="radio" name="status0" checked="checked"/>启用 <input type="radio" name="status0"/>禁用</td></tr>
		<tr><td colspan="2" style="text-align:center;height:">
		<input type="hidden" id="userId0" name="userId0" value="${sessionScope.memberSessionInfo.userId}" />"
		<input type="hidden" id="shipInfoId0" name="shipInfoId0" value="${shipInfo.id}" />
		<input type="button" value=" 提 交 " class="btn1" onclick="submitShipDirectory()"/></td></tr>
	</table>
	</div>
</div>  
    <script src="<%=basePath%>js/win.js" type="text/javascript"></script>
</div>
<script  type="text/javascript">
function addShipDirectory(){
	WIN.show('添加单证信息',$('winCon_1'),{height:400});
}
function editShipDirectory(id){
	WIN.show('修改单证信息',$('winCon_1'),{height:350});
	shipService.getShipDirectoryById(id,function(data){
		if(data==null){
			alert('获取数据出错!请重新刷新页面');
			WIN.close();
		}else{
			$('shipDirectoryId0').value=data.id;
			$('saveDate0').value=formatDate(data.saveDate);
			$('startDate0').value=formatDate(data.startDate);
			$('directory0').value=data.directory;
			$('amount0').value=data.amount;
			$('remark0').value=data.remark;
			if(data.status){$N('status0')[0].checked=true;}else{$N('status0')[1].checked=true;}	
		}	
	})
}
function delShipDirectory(id){
	if(confirm("删除单证信息，确定删除 ？")){
		WIN.showpg();
		shipService.delShipDirectoryById(id,{
			callback:function(f){WIN.closepg();alert("删除成功");reload();},
			exceptionHandler:function(message){WIN.closepg();alert("删除失败，请重试");},
			errorHander:function(err){}
		})
	}
}
/**/
function submitShipDirectory(){
	var user = {id:$('userId0').value};
	var shipInfo = {id:$('shipInfoId0').value};
	if(user ==''){alert('无法获取登录信息，请重新登录!');return;}
	if(shipInfo ==''){alert('无法获取船舶信息，请重新选择船舶信息!');return;}
	var shipDirectory={
			id:			$('shipDirectoryId0').value,
			saveDate:	$('saveDate0').value.trim()?new Date($('saveDate0').value.trim().replace(/-/g,"/")):'',
			startDate:	$('startDate0').value.trim()?new Date($('startDate0').value.trim().replace(/-/g,"/")):'',
			directory:	$('directory0').value,
			amount:     $('amount0').value,
			remark:     $('remark0').value,
			status:		$N('status0')[0].checked,
			user:       user,
			shipInfo:   shipInfo
	}	
	if(''==shipDirectory.directory){alert('单证目录不能为空');return;}
	if(''==shipDirectory.startDate){alert('日期不能为空');return;}
	submit(shipDirectory);	
}
function submit(info){
	WIN.close();
	WIN.showpg();
	shipService.editShipDirectory(info,{
		callback:function(f){WIN.closepg();alert("操作成功");reload();},
		exceptionHandler:function(message){WIN.closepg();alert(message);alert("操作失败，请重试");},
		errorHander:function(err){}
	})
}

</script>
</body>
</html>
